$(function () {
	$("#jqGrid").jqGrid({
		url: baseURL + '/merchant/applyRecordList',
		datatype: "json",
		colModel: [         
		{ label: 'ID', name: 'id', width: 30, key: true },
		{ label: '申请人', name: 'proposer', width: 60 },
		{ label: '商品名称', name: 'name', width: 100 },
		{ label: '平台账号', name: 'taobaoName', width: 100 },
		{ label: '本月已完成任务数', name: 'applycount', width: 80 },
		{ label:"QQ",name:"qqId",width: 100 ,formatter: function(value, options, row){
                var rtn='--'
                if(value !=null && value !='null'){
                    var rtn='<a href="tencent://message/?uin='+value+'&Site=http://vps.shuidazhe.com&Menu=yes">'+value+'</a>' ;
                }
                return  rtn;
            }},
		{label:"状态",name:"status",width: 100,formatter: function(value, options, row){
			if(value ==1){
				return "待填写订单号";
			}
			else if(value ==3){
				return "待好评"
			}
		}}
		],
		viewrecords: true,
		height: 555,
		rowNum: 10,
		rowList : [10,30,50],
		rownumbers: true, 
		rownumWidth: 25, 
		autowidth:true,
		multiselect: true,
		pager: "#jqGridPager",
		jsonReader : {
			root: "data.data",
			page: "data.pageNo",
			records: "data.totalNum"
		},
		prmNames : {
			page:"pageNo", 
			rows:"pageSize", 
			order: "order"
		},
		gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});
function pass(id,trailId){
	confirm("您确定通过吗？",function () {
		var data={"id":id,"trailId":trailId};
		$.ajax({
			type: "POST",
			url: baseURL + "/merchant/pass",
			dataType: "json",
			contentType:"application/json",
			data:JSON.stringify(data),
			success: function(r){
				if (r.code===0) {
					alert(r.info,function () {
						location.reload();
					})
                    // var page = $("#jqGrid").jqGrid('getGridParam','page');
                    // $("#jqGrid").jqGrid('setGridParam',{
                    //     postData:{'key': vm.q.key},
                    //     page:page
                    // }).trigger("reloadGrid");
                }else{
                	alert(r.info);
                }

            }
        });
	})
};

function refuse(id,trailId){
	vm.refuseObj.id=id;
	vm.refuseObj.trailId=trailId;
	$("#showModel").click();
};
var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			key: null
		},
		showList: true,
		title: null,
		refuseObj:{
			"comments":null,
			"id":null,
			"trailId":null
		}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		reload: function () {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
				postData:{'key': vm.q.key},
				page:page
			}).trigger("reloadGrid");
		},
		subRefuse:function () {
			$.ajax({
				type: "POST",
				url: baseURL + "/merchant/refuse",
				dataType: "json",
				contentType:"application/json",
				data:JSON.stringify(vm.refuseObj),
				success: function(r){
					if (r.code===0) {
						alert(r.info,function () {
							location.reload();
						})
					}else{
						alert(r.info);
					}

				}
			});
		}
	},
	mounted:function () {
	}
});